from django.db import models

# Create your models here.


class HomeFirstCategoryModel(models.Model):
    name = models.CharField(max_length=20, unique=True,verbose_name='一级分类名称')

    class Meta:
        db_table = 'home_first_category'
        verbose_name = '首页一级分类'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class HomeSecondCategoryModel(models.Model):
    name = models.CharField(max_length=20, unique=True,verbose_name='二级分类名称')
    home_first_category = models.ForeignKey('HomeFirstCategoryModel', related_name='home_second_category_home_first_category',
                                       db_constraint=False,on_delete=models.DO_NOTHING,verbose_name='所属二级分类')

    class Meta:
        db_table = 'home_second_category'
        verbose_name = '首页二级分类'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class HomeThirdCategoryModel(models.Model):
    name = models.CharField(max_length=20, verbose_name='三级分类名称')
    home_second_category = models.ForeignKey('HomeSecondCategoryModel',
                                            related_name='home_third_category_home_second_category',
                                            db_constraint=False, on_delete=models.DO_NOTHING,verbose_name='所属三级分类')
    class Meta:
        db_table = 'home_third_category'
        verbose_name = '首页三级分类'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
